from gevent import joinall,spawn,monkey;monkey.patch_all()
import requests
from threading import current_thread

def parse_page(res):
    print('%s PARSE %s' %(current_thread().getName(),len(res)))

def get_page(url,callback=parse_page):
    print('%s GET %s' %(current_thread().getName(),url))
    response=requests.get(url)
    if response.status_code == 200:
        callback(response.text)

if __name__ == '__main__':
    urls=[
        'https://www.baidu.com',
        'https://www.taobao.com',
        'https://www.openstack.org',
    ]
    tasks=[]
    for url in urls:
        tasks.append(spawn(get_page,url))

    joinall(tasks)